package com.sunqianhu.design_patterns_23.behavioral.iterator;

import java.util.List;

public class ConcreteIterator implements Iterator{
    private List<Book> books;
    private int position = 0;

    public ConcreteIterator(List<Book> books) {
        this.books = books;
    }

    @Override
    public boolean hasNext() {
        return position < books.size();
    }

    @Override
    public Book next() {
        if (this.hasNext()) {
            return books.get(position++);
        } else {
            return null;
        }
    }
}
